package com.walle.eve.web;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.walle.eve.service.UserService;

@RestController
@RequestMapping(value = "/api/user")
public class UserController {
	
	@Autowired
	private UserService userSerivce;
	
	private Logger logger = LoggerFactory.getLogger(getClass());

	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	public Map<String, Object> getUserInfo(@PathVariable String id) {
		return userSerivce.getUserInfoById(id);
	}
	
	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public List<Map<String, Object>> getUserList() {
		return userSerivce.getUserList();
	}
	
	@RequestMapping(value = "/add/{userName}/{realName}", method = RequestMethod.GET)
	public String addUser(@PathVariable String userName, @PathVariable String realName) {
		userSerivce.addUser(userName, realName);
		return "suceess";
	}
	
	@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
	public String deleteUser(@PathVariable String id) {
		userSerivce.deleteUser(id);
		return "suceess";
	}
}
